<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function laodScript(url, callback) {
        var script = document.createElement("script");
        script.type = "text/javascript";

        if (script.readyState) {
          // ie
          script.onreadystatechange = function () {
            if (
              script.readyState == "loaded" ||
              script.readyState == "complete"
            ) {
              script.onreadystatechange = null;
              callback();
            }
          };
        } else {
          script.onload = function () {
            callback();
          };
        }
        script.src = url;
        document.getElementsByTagName("head")[0].appendChild(script);
      }

      // 使用
      loadScript("./a.js", function () {
        loadScript("./b.js", function () {
          loadScript("./c.js", function () {
            console.log("加载完成");
          });
        });
      });
    </script>
  </body>
</html>
